import java.util.HashSet;

public class demo7 {
    public static void main(String[] args) {
        int i = 1;
        while(true){
            HashSet<Object> set = new HashSet<>();
            int ping = i * i;
            int li = i * i * i;
            String s = "" + ping +li;
            if(s.length() == 10){
                char[] chars = s.toCharArray();
                for (int j = 0; j < 10; j++) {
                    set.add(chars[j]);
                }
                if (set.size() == 10){
                    System.out.println(i);
                    break;
                }
            }
            i++;
        }

    }
}
